package user

import (
	"API/client"
	"API/request"
	"API/response"
	"context"
	"github.com/gin-gonic/gin"
	user "user_server/proto"
)

func FindLuckyHandler(c *gin.Context) {
	var req request.FindLuckyRequest
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(400, gin.H{"error": err.Error()})
		return
	}
	userId := c.GetUint("userId")
	lucky, err := client.UserFindLucky(context.Background(), &user.GetLuckyDrawRecordsRequest{
		UserId:   int32(userId),
		Page:     int32(req.Page),
		PageSize: int32(req.Size),
	})
	if err != nil {
		response.CurrencyErrResponse(c, 500, err.Error())
		return
	}
	response.CurrencySuccessResponse(c, "查询成功", map[string]interface{}{
		"luckyDrawRecords": lucky.Records,
	})
}
